package com.mo.ld.activity.gate

import android.graphics.Color
import android.os.Bundle
import com.github.mikephil.charting.data.CandleEntry
import com.mo.ld.databinding.ActGateDetailBinding
import com.mo.lib.ui.activity.BaseVbActivity
import com.mo.lib.utils.intentExtrasString
import com.mo.lib.view.chart.*

/**
 * @ author：mo
 * @ data：2022/4/15:9:34
 * @ 功能：
 */
class GateDeatilActivity : BaseVbActivity<ActGateDetailBinding>() {
    private val name: String? by intentExtrasString()
    override fun initView(savedInstanceState: Bundle?) {
        super.initView(savedInstanceState)
        viewBinding.cscCionDetail.setChartSetting().setDescription().setLegend().setAxisLeft().setAxisRight().setXAxis()
        getCandlestick(name!!, 60 * 60 * 4, 4 * 20*5) {
            if (this.isNotEmpty()){
                val candleEntry: ArrayList<CandleEntry> = ArrayList()
                for ((indext, itBean) in this.withIndex()) {
                    candleEntry.add(CandleEntry((indext + 1).toFloat(), itBean.height.toFloat(), itBean.low.toFloat(), itBean.open.toFloat(), itBean.close.toFloat()))
                }
                viewBinding.cscCionDetail.addCandleStickData(Color.GREEN, Color.RED, candleEntry)
            }
        }
    }

    override fun initData() {

    }
}